package dingding.使用线程;

import java.util.ArrayList;
import java.util.List;

public class Demo4 {
    public static void main(String[] args) {

        long memory = Runtime.getRuntime().maxMemory();
        System.out.println(String.format("%d (%.2f M)", memory, (double) memory / (1024 * 1024)));
//        List<Object> heapList = new ArrayList<>();

         new Thread(() -> {
            List<byte[]> list = new ArrayList<>();
//            heapList.addAll(list);
            while (true) {
                System.out.println(Thread.currentThread() + "==");
                byte[] b = new byte[1024 * 10240 * 1];
                list.add(b);
                try {
                    Thread.sleep(3000);
                } catch (Exception e) {
                    e.printStackTrace();
                }
//                byte[] a = b;
//                heapList.add(a);
            }

        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    }
                    System.out.println("test");
                }

            }
        }).start();


    }
}
